<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QGraphicsSvgItem Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGraphicsSvgItem Class Reference<br /><sup><sup>[<a href="qtsvg.html">QtSvg</a> module]</sup></sup></h1><p>The QGraphicsSvgItem class is a <a href="qgraphicsitem.html">QGraphicsItem</a> that can be used to render
the contents of SVG files. <a href="#details">More...</a></p>

<p>Inherits <a href="qgraphicsobject.html">QGraphicsObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicssvgitem.html#QGraphicsSvgItem">__init__</a></b> (<i>self</i>, QGraphicsItem&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#QGraphicsSvgItem-2">__init__</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, QGraphicsItem&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QRectF <b><a href="qgraphicssvgitem.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qgraphicssvgitem.html#elementId">elementId</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicssvgitem.html#isCachingEnabled">isCachingEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QSize <b><a href="qgraphicssvgitem.html#maximumCacheSize">maximumCacheSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#paint">paint</a></b> (<i>self</i>, QPainter&#160;<i>painter</i>, QStyleOptionGraphicsItem&#160;<i>option</i>, QWidget&#160;<i>widget</i>&#160;=&#160;None)</li><li><div class="fn" />QSvgRenderer <b><a href="qgraphicssvgitem.html#renderer">renderer</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setCachingEnabled">setCachingEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setElementId">setElementId</a></b> (<i>self</i>, QString&#160;<i>id</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setMaximumCacheSize">setMaximumCacheSize</a></b> (<i>self</i>, QSize&#160;<i>size</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a></b> (<i>self</i>, QSvgRenderer&#160;<i>renderer</i>)</li><li><div class="fn" />int <b><a href="qgraphicssvgitem.html#type">type</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsSvgItem class is a <a href="qgraphicsitem.html">QGraphicsItem</a> that can be used to render
the contents of SVG files.</p>
<p>QGraphicsSvgItem provides a way of rendering SVG files onto
<a href="qgraphicsview.html">QGraphicsView</a>. QGraphicsSvgItem
can be created by passing the SVG file to be rendered to its
constructor or by explicit setting a shared <a href="qsvgrenderer.html">QSvgRenderer</a> on it.</p>
<p>Note that setting <a href="qsvgrenderer.html">QSvgRenderer</a>
on a QGraphicsSvgItem doesn't make the item take ownership of the
renderer, therefore if using <a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a>()
method one has to make sure that the lifetime of the <a href="qsvgrenderer.html">QSvgRenderer</a> object will be at least as
long as that of the QGraphicsSvgItem.</p>
<p>QGraphicsSvgItem provides a way of rendering only parts of the
SVG files via the setElementId. If <a href="qgraphicssvgitem.html#elementId-prop">setElementId</a>() method is
called, only the SVG element (and its children) with the passed id
will be renderer. This provides a convenient way of selectively
rendering large SVG files that contain a number of discrete
elements. For example the following code renders only jokers from a
SVG file containing a whole card deck:</p>
<pre class="cpp">
 <span class="type"><a href="qsvgrenderer.html">QSvgRenderer</a></span> <span class="operator">*</span>renderer <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qsvgrenderer.html">QSvgRenderer</a></span>(QLatin1String(<span class="string">"SvgCardDeck.svg"</span>));
 <span class="type">QGraphicsSvgItem</span> <span class="operator">*</span>black <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QGraphicsSvgItem</span>();
 <span class="type">QGraphicsSvgItem</span> <span class="operator">*</span>red   <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QGraphicsSvgItem</span>();

 black<span class="operator">-</span><span class="operator">&gt;</span><a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a>(renderer);
 black<span class="operator">-</span><span class="operator">&gt;</span><a href="qgraphicssvgitem.html#elementId-prop">setElementId</a>(QLatin1String(<span class="string">"black_joker"</span>));

 red<span class="operator">-</span><span class="operator">&gt;</span><a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a>(renderer);
 red<span class="operator">-</span><span class="operator">&gt;</span><a href="qgraphicssvgitem.html#elementId-prop">setElementId</a>(QLatin1String(<span class="string">"red_joker"</span>));
</pre>
<p>Size of the item can be set via the <a href="qrectf.html#setSize">setSize()</a> method of the <a href="qgraphicssvgitem.html#boundingRect">bounding rectangle</a> or via
direct manipulation of the items transformation matrix.</p>
<p>By default the SVG rendering is cached using <a href="qgraphicsitem.html#CacheMode-enum">QGraphicsItem.DeviceCoordinateCache</a>
mode to speedup the display of items. Caching can be disabled by
passing <a href="qgraphicsitem.html#CacheMode-enum">QGraphicsItem.NoCache</a> to
the <a href="qgraphicsitem.html#setCacheMode">QGraphicsItem.setCacheMode</a>()
method.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsSvgItem" />QGraphicsSvgItem.__init__ (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new SVG item with the given <i>parent</i>.</p>


<h3 class="fn"><a name="QGraphicsSvgItem-2" />QGraphicsSvgItem.__init__ (<i>self</i>, QString&#160;<i>fileName</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new item with the given <i>parent</i> and loads the
contents of the SVG file with the specified <i>fileName</i>.</p>


<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QGraphicsSvgItem.boundingRect (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#boundingRect">QGraphicsItem.boundingRect</a>().</p>
<p>Returns the bounding rectangle of this item.</p>


<h3 class="fn"><a name="elementId" />QString QGraphicsSvgItem.elementId (<i>self</i>)</h3><h3 class="fn"><a name="isCachingEnabled" />bool QGraphicsSvgItem.isCachingEnabled (<i>self</i>)</h3><h3 class="fn"><a name="maximumCacheSize" /><a href="qsize.html">QSize</a> QGraphicsSvgItem.maximumCacheSize (<i>self</i>)</h3><h3 class="fn"><a name="paint" />QGraphicsSvgItem.paint (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>painter</i>, <a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a>&#160;<i>option</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>&#160;=&#160;None)</h3><p>Reimplemented from <a href="qgraphicsitem.html#paint">QGraphicsItem.paint</a>().</p>


<h3 class="fn"><a name="renderer" /><a href="qsvgrenderer.html">QSvgRenderer</a> QGraphicsSvgItem.renderer (<i>self</i>)</h3><p>Returns the currently use <a href="qsvgrenderer.html">QSvgRenderer</a>.</p>


<h3 class="fn"><a name="setCachingEnabled" />QGraphicsSvgItem.setCachingEnabled (<i>self</i>, bool)</h3><h3 class="fn"><a name="setElementId" />QGraphicsSvgItem.setElementId (<i>self</i>, QString&#160;<i>id</i>)</h3><h3 class="fn"><a name="setMaximumCacheSize" />QGraphicsSvgItem.setMaximumCacheSize (<i>self</i>, <a href="qsize.html">QSize</a>&#160;<i>size</i>)</h3><h3 class="fn"><a name="setSharedRenderer" />QGraphicsSvgItem.setSharedRenderer (<i>self</i>, <a href="qsvgrenderer.html">QSvgRenderer</a>&#160;<i>renderer</i>)</h3><p>Sets <i>renderer</i> to be a shared <a href="qsvgrenderer.html">QSvgRenderer</a> on the item. By using this
method one can share the same <a href="qsvgrenderer.html">QSvgRenderer</a> on a number of items. This
means that the SVG file will be parsed only once. <a href="qsvgrenderer.html">QSvgRenderer</a> passed to this method has to
exist for as long as this item is used.</p>


<h3 class="fn"><a name="type" />int QGraphicsSvgItem.type (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#type">QGraphicsItem.type</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>